﻿using System.Diagnostics;

namespace StarsAdmin.Core.Extensions
{
    public class StopwatchExtensions
    {
        private static readonly Stopwatch _watch = Stopwatch.StartNew();

        /// <summary>
        /// 开始计时
        /// </summary>
        public static void Start()
        {
            _watch.Start();
        }

        /// <summary>
        /// 停止计时
        /// </summary>
        public static void Stop()
        {
            _watch.Stop();
        }

        /// <summary>
        /// 获取已经经过的时间（毫秒）
        /// </summary>
        /// <returns></returns>
        public static long GetElapsedMilliseconds()
        {
            return _watch.ElapsedMilliseconds;
        }
    }
}